<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="stylesheet" type="text/css" href="${staticpath}/front/dist/css/sm.css">
    <link rel="stylesheet" type="text/css" href="${staticpath}/front/dist/css/sm-extend.css">
    <link rel="stylesheet" type="text/css" href="${staticpath}/front/dist/css/print.css">
    <link rel="stylesheet" type="text/css" href="${staticpath}/front/dist/css/base.css">
    <title>填写信息</title>
</head>
<body>
<style>
    .list-block .item-title.label{
        width: 4rem;
    }
</style>
<div class="page-group">
    <div class="page">
        <!--头部内容 !-->
        <header class="bar bar-nav">
            <a class="icon icon-left pull-left" href="${basepath}/rest/front/product/toAbout"></a>

            <h1 class="title">填写信息</h1>
        </header>
        <div class="content addAddress">
            <div class="list-block">
                <ul>
                    <!-- Text inputs -->
                    <li>
                        <div class="item-content">
                            <div class="item-media"><i class="icon icon-form-name"></i></div>
                            <div class="item-inner">
                                <div class="item-title label">联系人</div>
                                <div class="item-input">
                                    <input type="text" class="r-name" placeholder="请填写联系人">
                                </div>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="item-content">
                            <div class="item-media"><i class="icon icon-form-email"></i></div>
                            <div class="item-inner">
                                <div class="item-title label">联系电话</div>
                                <div class="item-input">
                                    <input type="tel" class="r-tel" placeholder="请填写联系电话" onkeyup="value=value.replace(/[^\d]/g,'')">
                                </div>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="item-content">
                            <div class="item-media"><i class="icon icon-form-email"></i></div>
                            <div class="item-inner">
                                <div class="item-title label">QQ号</div>
                                <div class="item-input">
                                    <input type="text" class="r-qq" placeholder="请填写联系QQ号" onkeyup="value=value.replace(/[^\d]/g,'')">
                                </div>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="item-content">
                            <div class="item-media"><i class="icon icon-form-email"></i></div>
                            <div class="item-inner">
                                <div class="item-title label">微信号</div>
                                <div class="item-input">
                                    <input type="text" class="r-weChat" placeholder="请填写微信号" onkeyup="value = value.replace(/[\u4e00-\u9fa5]/g, '')"/>
                                </div>
                            </div>
                        </div>
                    </li>
                </ul>
            </div>
            <div class="saveInfBtn url" data-url="${basepath}/rest/front/product/toAbout">
                <a class="button">保存</a>
            </div>
        </div>
    </div>
    <script type='text/javascript' src='${staticpath}/front/dist/js/lib/zepto.js' charset='utf-8'></script>
    <script type="text/javascript">$.config = {router: false}</script>
    <script type='text/javascript' src='${staticpath}/front/dist/js/lib/sm.js' charset='utf-8'></script>
    <script type='text/javascript' src='${staticpath}/front/dist/js/lib/sm-extend.js' charset='utf-8'></script>
    <script type="text/javascript">
        $('.saveInfBtn').click(function () {
            var name = $('.r-name').val(),
                    phone = $('.r-tel').val(),
                    qq = $('.r-qq').val(),
                    weChat = $('.r-weChat').val();
            if (name == '' || phone == '' || qq == '' || weChat == '') {
                $.alert('请先写完整信息');
                return;
            } else if(!(/^1(3|4|5|7|8)\d{9}$/.test(phone))){
                $.alert('手机输入错误');
            } else {

                $.ajax({
                    type: "POST",
                    dataType: 'json',
                    url: '/rest/front/product/insertMember',
                    data: {
                        name: name,
                        phone: phone,
                        qq: qq,
                        weChat: weChat
                    },
                    success: function (data) {
                        $.toast("保存成功");
                        if (data.success) {
                            window.location.href = $('.saveInfBtn').attr('data-url');
                        } else {
                            $.alert(data.message);
                        }
                    }
                })
            }
        });

        $.init();
    </script>
</div>
</body>

</html>
